<template>
  <el-image
    style="width: 200px"
    :src="captcha"
    fit="contain"
    @click="refreshCode()"
  ></el-image>
</template>

<script setup>
import { onMounted } from "vue";
import { baseURL } from "../config/axios.config";

const key = ref("");
const captcha = ref("");
const emits = defineEmits(["randomKey"]);

const refreshCode = () => {
  emits("randomKey", (data) => {
    key.value = data;
  });
  captcha.value = `${baseURL}/captcha?t=${key.value}`;
};
onMounted(refreshCode);
</script>
